<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <img id="capt" src="" /><br/>
    <input id="usename" placeholder="请输入用户名" /><br/>
    <input id="password" placeholder="请输入密码" /><br/>
    <input id="captvalue" placeholder="请输入验证码" /><br/>
    <input id="verifyid" /><br/>
    <input type="button" name="save" value="提交" id="submit" />
    <div>
        <input type="file" name="" id="">
    </div>
    <script src="https://lib.baomitu.com/axios/0.21.4/axios.js"></script>
    <script>
        // axios.defaults.withCredentials = true
        axios.request({
            headers: {
                "Content-Type": "application/json"
            },
            transformRequest: [function(data) {
                data = JSON.stringify(data)
                return data
            }],
            url: 'http://localhost:8099/api/login_sms',
            method: 'post',
            params: {},
            data: {
                "phone": "15436244961",
                "code": "715923"
            }
        })
        

        axios.request({
            headers: {
                "Content-Type": "application/json"
            },
            transformRequest: [function(data) {
                data = JSON.stringify(data)
                return data
            }],
            url: 'http://localhost:8099/api/captcha',
            method: 'get',
            params: {},
            data: {
            }
        }).then(res => {
            console.log(res)
            const img = document.querySelector("img#capt")
            img.src = res.data && res.data.data.base_64_blob
            const verifyid = document.querySelector("input#verifyid")
            verifyid.value = res.data && res.data.data.id
        })

        const btn = document.querySelector("input#submit")
        btn.onclick = function() {
            const usename = document.querySelector("input#usename")
            const password = document.querySelector("input#password")
            const captvalue = document.querySelector("input#captvalue")
            const verifyid = document.querySelector("input#verifyid")
            axios.request({
                headers: {
                    "Content-Type": "application/json"
                },
                transformRequest: [function(data) {
                    data = JSON.stringify(data)
                    return data
                }],
                url: 'http://localhost:8099/api/login_pwd',
                method: 'post',
                params: {},
                data: {
                    name: usename.value,
                    pwd: password.value,
                    value: captvalue.value,
                    id: verifyid.value
                }
            }).then(res => {
                console.log(res)
            })

        }

    </script>
</body>
</html>